//package org.example.domain.strategy.service.rule.filter.impl;
//
//import lombok.extern.slf4j.Slf4j;
//import org.example.domain.strategy.model.entity.RuleActionEntity;
//import org.example.domain.strategy.model.entity.RuleMatterEntity;
//import org.example.domain.strategy.model.vo.RuleLogicCheckTypeVO;
//import org.example.domain.strategy.repository.IStrategyRepository;
//import org.example.domain.strategy.service.annotation.LoginStrategy;
//import org.example.domain.strategy.service.rule.filter.ILogicFilter;
//import org.example.domain.strategy.service.rule.filter.factory.DefaultLogicFactory;
//import org.example.types.common.Constants;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//
///**
// *过滤黑名单的规则
// */
//@Slf4j
//@Component
//@LoginStrategy(logicModel = DefaultLogicFactory.LogicModel.RULE_BLACKLIST)
//public class RuleBackListLogicFilter implements ILogicFilter<RuleActionEntity.RaffleBeforeEntity>{
//
//    @Resource
//    private IStrategyRepository strategyRepository;
//
//    @Override
//    public RuleActionEntity<RuleActionEntity.RaffleBeforeEntity> filter(RuleMatterEntity ruleMatterEntity) {
//        log.info("规则过滤-黑名单 userId:{} strategyId:{} ruleModel:{}", ruleMatterEntity.getUserId(), ruleMatterEntity.getStrategyId(), ruleMatterEntity.getRuleModel());
//        String userId = ruleMatterEntity.getUserId();
//        //查询规则配置
//        String ruleValue = strategyRepository.queryStrategyRuleValue(ruleMatterEntity.getStrategyId(),ruleMatterEntity.getAwardId(),ruleMatterEntity.getRuleModel());
//       ///
//        if(ruleValue == null){
//           return RuleActionEntity.<RuleActionEntity.RaffleBeforeEntity>builder()
//                   .code(RuleLogicCheckTypeVO.ALLOW.getCode())
//                   .info(RuleLogicCheckTypeVO.ALLOW.getInfo())
//                   .build();
//       }
//        String[] splitRuleValue = ruleValue.split(Constants.COLON);
//        Integer awardId = Integer.parseInt(splitRuleValue[0]);
//        //过滤其他规则（黑名单）
//        //
//        String[] userBlackIds = splitRuleValue[1].split(Constants.SPLIT);
//        for (String userBlackId : userBlackIds) {
//            if (userId.equals(userBlackId)) {
//                return RuleActionEntity.<RuleActionEntity.RaffleBeforeEntity>builder()
//                        .ruleModel(DefaultLogicFactory.LogicModel.RULE_BLACKLIST.getCode())
//                        .data(RuleActionEntity.RaffleBeforeEntity.builder()
//                                .strategyId(ruleMatterEntity.getStrategyId())
//                                .awardId(awardId)
//                                .build())
//                        .code(RuleLogicCheckTypeVO.TAKE_OVER.getCode())
//                        .info(RuleLogicCheckTypeVO.TAKE_OVER.getInfo())
//                        .build();
//            }
//
//        }
//        return RuleActionEntity.<RuleActionEntity.RaffleBeforeEntity>builder()
//                .code(RuleLogicCheckTypeVO.ALLOW.getCode())
//                .info(RuleLogicCheckTypeVO.ALLOW.getInfo())
//                .build();
//    }
//}
